**# Title :Economic Sanctions and Political Stability: Investigating the Mediating Role of Government Effectiveness

**# A. Data Setup and Baseline Diagnostics
//A1. Panel Structure and Sample Description
xtset id year

Panel variable: id (strongly balanced)
 Time variable: year, 2000 to 2022
         Delta: 1 unit
		 	 
//A2. Descriptive Statistics  
sum Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness

//A3. Pairwise Correlations  
pwcorr Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness ,sig

//A4. Multicollinearity Check  
reg Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Inflation_Rate unemployment_rate Trade_Openness Government_Spending
vif

**# B. Baseline Panel Models
//B1. Model Selection: (Hausman Test)
xtreg Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness ,fe
estimates store fe
xtreg Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness
estimates store re
hausman fe re

//B2. Baseline Fixed-Effects Mediation Components  
xtreg Gov_Effectiveness Economic_Sanctions log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate , fe

xtreg Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness , fe

**# C. Structural Mediation Framework
//C1. Structural Mediation Estimation (GSEM Joint System)
gsem  (Gov_Effectiveness = Economic_Sanctions log_ppp Population_size__in_millions Government_Spending  Inflation_Rate unemployment_rate Trade_Openness )   (Political_Stability = Economic_Sanctions Gov_Effectiveness   log_ppp Population_size__in_millions       Government_Spending Inflation_Rate       unemployment_rate Trade_Openness ),   latent(id) vce(robust)

**# D. Dynamic Panel Endogeneity Controls
//D1. Dynamic Government Effectiveness Model (System GMM)
xtabond2 Gov_Effectiveness L.Gov_Effectiveness Economic_Sanctions  log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness, gmm(L.Political_Stability Gov_Effectiveness, lag(1 3)) iv(Economic_Sanctions ) twostep

//D2. Dynamic Political Stability Model with Mediation (System GMM)
xtabond2 Political_Stability L.Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness, gmm(L.Political_Stability Gov_Effectiveness, lag(1 3)) iv(Economic_Sanctions ) twostep

**# E. Heterogeneity and Theory-Driven Extensions
gen Eco_s_X_Gov_Effect = Economic_Sanctions * Gov_Effectiveness 

xtreg Political_Stability Economic_Sanctions Gov_Effectiveness Eco_s_X_Gov_Effect log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness , fe

xtabond2 Political_Stability L.Political_Stability Economic_Sanctions Gov_Effectiveness Eco_s_X_Gov_Effect  log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness, gmm(L.Political_Stability Gov_Effectiveness , lag(1 3)) iv((Economic_Sanctions Eco_s_X_Gov_Effect log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness)) twostep		
 
**# F. Measurement Validity and Robustness to Alternative Conceptions of Stability
//F1. Sanction-Type Heterogeneity: Trade vs Financial Sanctions
gsem  (Gov_Effectiveness = trade log_ppp Population_size__in_millions Government_Spending  Inflation_Rate unemployment_rate Trade_Openness )   (Political_Stability = trade Gov_Effectiveness   log_ppp Population_size__in_millions       Government_Spending Inflation_Rate       unemployment_rate Trade_Openness ),   latent(id) vce(robust)

gsem  (Gov_Effectiveness = financial log_ppp Population_size__in_millions Government_Spending  Inflation_Rate unemployment_rate Trade_Openness )   (Political_Stability = financial Gov_Effectiveness   log_ppp Population_size__in_millions       Government_Spending Inflation_Rate       unemployment_rate Trade_Openness ),   latent(id) vce(robust)


//F2. Outcome-Specific Instability Measures (Beyond WGI Composite)
//mass mobilization 
gsem  (Gov_Effectiveness = Economic_Sanctions log_ppp Population_size__in_millions Government_Spending  Inflation_Rate unemployment_rate Trade_Openness )   ( v2cagenmob = Economic_Sanctions Gov_Effectiveness   log_ppp Population_size__in_millions       Government_Spending Inflation_Rate       unemployment_rate Trade_Openness ),   latent(id) vce(robust)
//CSO anti-system movements
gsem  (Gov_Effectiveness = Economic_Sanctions log_ppp Population_size__in_millions Government_Spending  Inflation_Rate unemployment_rate Trade_Openness )   ( v2csantimv = Economic_Sanctions Gov_Effectiveness   log_ppp Population_size__in_millions       Government_Spending Inflation_Rate       unemployment_rate Trade_Openness ),   latent(id) vce(robust)
//political violence 
gsem  (Gov_Effectiveness = Economic_Sanctions log_ppp Population_size__in_millions Government_Spending  Inflation_Rate unemployment_rate Trade_Openness )   ( v2caviol = Economic_Sanctions Gov_Effectiveness   log_ppp Population_size__in_millions       Government_Spending Inflation_Rate       unemployment_rate Trade_Openness ),   latent(id) vce(robust)

**# G. Mediation Inference and Effect Decomposition
//G1. Formal Inference for the Indirect Effect in FE (Bootstrap a×b)
program define fe_mediation, rclass

    quietly xtreg Gov_Effectiveness Economic_Sanctions log_ppp         Population_size__in_millions Government_Spending         Inflation_Rate unemployment_rate, fe

    scalar a = _b[Economic_Sanctions]
	
    quietly xtreg Political_Stability Economic_Sanctions Gov_Effectiveness         log_ppp Population_size__in_millions Government_Spending         Inflation_Rate unemployment_rate Trade_Openness, fe
	

    scalar b = _b[Gov_Effectiveness]

    return scalar indirect = a*b
end

bootstrap r(indirect), reps(1000) seed(12345): fe_mediation

//G2. Distributional Heterogeneity: Quantile Effects and Mediated Shares
xtqreg Gov_Effectiveness Economic_Sanctions log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate , quantile(0.25)
xtqreg Gov_Effectiveness Economic_Sanctions log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate , quantile(0.50)
xtqreg Gov_Effectiveness Economic_Sanctions log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate , quantile(0.75)

xtqreg Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness , quantile(0.25)
xtqreg Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness , quantile(0.50)
xtqreg Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness , quantile(0.75)

**# H. Global Shocks, Omitted Variables, and Expanded Controls
// H1. Two-Way Fixed Effects (Country + Year) to Absorb Common Global Shocks
xtreg Political_Stability Economic_Sanctions Gov_Effectiveness log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness i.year , fe

//H2. Exposure and Institutional Controls: Globalization and Regime Proxies
xtreg Political_Stability Economic_Sanctions Gov_Effectiveness socialglobalizationindex0100  log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness i.year , fe

xtreg Political_Stability Economic_Sanctions Gov_Effectiveness   Voice_Accountability  log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness i.year , fe

//H3. Resource Dependence Robustness (Natural Resource Income Share)
xtreg Gov_Effectiveness Economic_Sanctions incomefromnaturalresourcespercen log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness, fe

xtreg Political_Stability Economic_Sanctions Gov_Effectiveness incomefromnaturalresourcespercen  log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness , fe


**# I. Causal Timing and Pre-Trends (data _event File)
//I1. Event-Study Around Sanctions Onset (Pre-Trend and Post-Effect Dynamics)
* Panel settings
xtset id year

* First year with sanctions (onset)
bys id (year): egen onset = min(cond(Economic_Sanctions>0, year, .))

* Relative time to onset
gen rel = year - onset

* Treated indicator
gen treated = !missing(onset)

* Keep a symmetric window (example: -5 to +5)
gen Dm5 = (rel == -5)
gen Dm4 = (rel == -4)
gen Dm3 = (rel == -3)
gen Dm2 = (rel == -2)
gen Dm1 = (rel == -1)

* omit rel = -1 as baseline

gen D0  = (rel == 0)
gen Dp1 = (rel == 1)
gen Dp2 = (rel == 2)
gen Dp3 = (rel == 3)
gen Dp4 = (rel == 4)
gen Dp5 = (rel == 5)

keep if treated==1 & inrange(rel,-5,5)

* Event-study TWFE (country FE via xtreg, year FE via i.year)
xtreg Political_Stability  Dm5 Dm4 Dm3 Dm2 D0 Dp1 Dp2 Dp3 Dp4 Dp5 log_ppp Population_size__in_millions Government_Spending Inflation_Rate unemployment_rate Trade_Openness i.year, fe vce(cluster id)

test Dm5 Dm4 Dm3 Dm2

 ( 1)  Dm5 = 0
 ( 2)  Dm4 = 0
 ( 3)  Dm3 = 0
 ( 4)  Dm2 = 0

 F(  4,    82) =    2.49
      Prob > F =    0.0495

**# List of Countries
. tab Country
	  